package com.bgds.sys.module.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bgds.sys.module.entity.ClientConfig;
import com.bgds.sys.module.entity.Device;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lj
 * @since 2020-01-06
 */
@Repository
public interface DeviceMapper extends BaseMapper<Device> {



    /**
     * 菜单ID获取设备
     * @param permId
     * @return
     */
//    List<Device> seleteByPermId(@Param("permId") Long permId);

    /**
     * 父级编码获取设备
     * @param parentCode
     * @return
     */
    List<Device> seleteByParentCode(@Param("parentCode")String parentCode);

    @Select("SELECT dev.relation_id AS relationId,tb.seq_number AS seqNumber,tb.engName FROM \n" +
            " (SELECT attr.device_code,attr.seq_number,attr.eng_name as engName  FROM bgds_device_dynamic_attr attr\n" +
            "WHERE attr.msg_key=#{msgKey}) tb\n" +
            "INNER JOIN bgds_device dev\n" +
            "ON tb.device_code=dev.device_code\n" +
            "ORDER BY tb.seq_number asc")
    List<ClientConfig> getCoinfg(@Param("msgKey")String msgKey);

}
